#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    //
    treeView=new QTreeView(this);
    treeView->setGeometry(QRect(50,50,150,200));
    //定义列
    model=new QStandardItemModel(3,2);
    model->setHeaderData(0,Qt::Horizontal,"1Col");
    model->setHeaderData(1,Qt::Horizontal,"2Col");
    //定义节点
    QStandardItem * item1=new QStandardItem("数学");
    item1->setIcon(QIcon(":/b/c"));

    QStandardItem * item2=new QStandardItem("语文");
    item2->setIcon(QIcon(":/b/c"));

    QStandardItem * item3=new QStandardItem("外语");
    item3->setIcon(QIcon(":/b/c"));

    //外语子项
    QStandardItem * item4=new QStandardItem("外语A");
    item4->setIcon(QIcon("://d"));
    item3->appendRow(item4);
    //
    model->setItem(0,0,item1);
    model->setItem(1,0,item2);
    model->setItem(2,0,item3);
    //
    treeView->setModel(model);
}

MainWindow::~MainWindow()
{
    delete ui;
}
